package freejim.icu.highschoolhealthstatuspost.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DailyPostRepository extends JpaRepository<DailyPost,Long> {

    @Query(value = "select COUNT(*) from daily_post where date = ?1",nativeQuery = true)
    long getTodayPostNum(String date);

    @Query(value = "select * from daily_post where date = ?1",nativeQuery = true)
    List<DailyPost> getTodayPostList(String date);

    @Query(value = "select userid from daily_post where date = ?1",nativeQuery = true)
    List<Integer> getTodayPostIds(String date);

    @Query(value = "select * from daily_post where temperature<36 or temperature>37 or health = 0",nativeQuery = true)
    List<DailyPost> getUnNormalTemperatureList();

    @Query(value = "select * from daily_post where been_to_danger_area = 1",nativeQuery = true)
    List<DailyPost> getDangerTripList();

    @Query(value = "select * from daily_post where date = ?1 and userid = ?2",nativeQuery = true)
    DailyPost getTodayPostWithId(String date,long userid);





}
